<form class="form-horizontal" action="{{ route('commissions.pay_to_customer') }}" method="POST" enctype="multipart/form-data">
    @csrf
    <div class="modal-header">
    	<h5 class="modal-title h6">{{translate('Pay to customer')}}</h5>
    	<button type="button" class="close" data-dismiss="modal">
    	</button>
    </div>
    <div class="modal-body">
      <table class="table table-striped table-bordered" >
          <tbody>
                <tr>
                        <td>{{ translate('Due to customer') }}</td>
                        <td>{{single_price($customer_withdraw_request->amount)}}</td>
                </tr>
                
                <tr>
                        <td>{{ translate('Payment Cash Only') }}</td>
                        <td>{{ translate($customer_withdraw_request->user->cash_on_delivery_status ? 'Yes' : 'No')  }}</td>
                </tr>
                <tr>
                        <td>{{ translate('Payment Bank Only') }}</td>
                        <td>{{ translate($customer_withdraw_request->user->bank_payment_status ? 'Yes' : 'No')  }}</td>
                </tr>
                
                 @if($customer_withdraw_request->user->bank_payment_status == 1)
                    <tr>
                        <td>{{ translate('Bank Name') }}</td>
                        <td>{{ $customer_withdraw_request->user->bank_name }}</td>
                    </tr>
                    <tr>
                        <td>{{ translate('Bank Account Name') }}</td>
                        <td>{{ $customer_withdraw_request->user->bank_acc_name }}</td>
                    </tr>
                    <tr>
                        <td>{{ translate('Bank Account Number') }}</td>
                        <td>{{ $customer_withdraw_request->user->bank_acc_no }}</td>
                    </tr>
                    <tr>
                        <td>{{ translate('Bank Routing Number') }}</td>
                        <td>{{ $customer_withdraw_request->user->bank_routing_no }}</td>
                    </tr>
               @endif
                
            </tbody>
        </table>
            <input type="hidden" name="withdraw_request_id" value="{{ $customer_withdraw_request->id }}">
            <div class="form-group row">
                <label class="col-sm-3 col-from-label" for="amount">{{translate('Requested Amount')}}</label>
                <div class="col-sm-9">
                    {{single_price($customer_withdraw_request->amount)}}
                </div>
            </div>

            <div class="form-group row">
                <label class="col-sm-3 col-from-label" for="payment_option">{{translate('Payment Method')}}</label>
                <div class="col-sm-9">
                    <select name="payment_option" id="payment_option" class="form-control demo-select2-placeholder" required @if($customer_withdraw_request->status) disabled @endif>
                        <option value="">{{translate('Select Payment Method')}}</option>
                        @if($customer_withdraw_request->user->cash_on_delivery_status == 1)
                            <option value="cash" @if ($customer_withdraw_request->status && $customer_withdraw_request->payment->payment_method === 'cash') selected @endif >{{translate('Cash')}}</option>
                        @endif
                        @if($customer_withdraw_request->user->bank_payment_status == 1)
                            <option value="bank_payment" @if ($customer_withdraw_request->status && $customer_withdraw_request->payment->payment_method === 'bank_payment') selected @endif>{{translate('Bank Payment')}}</option>
                        @endif
                    </select>
                </div>
            </div>
            
            <div id="txn_div" class="form-group row" style="display: none;">
                <label class="col-sm-3 col-from-label" for="txn_code">{{translate('Txn Code')}}</label>
                <div class="col-sm-9">
                    <input type="text" name="txn_code" id="txn_code" class="form-control" value="@if ($customer_withdraw_request->status && $customer_withdraw_request->payment->payment_method === 'bank_payment') {{$customer_withdraw_request->payment->txn_code}} @endif">
                </div>
            </div>
            

    </div>
    <div class="modal-footer">
      
         @if(!$customer_withdraw_request->status && ($customer_withdraw_request->user->cash_on_delivery_status || $customer_withdraw_request->user->bank_payment_status))
            <button type="submit" class="btn btn-primary">{{translate('Pay')}}</button>
        @endif
     
      <button type="button" class="btn btn-light" data-dismiss="modal">{{translate('Cancel')}}</button>
    </div>
</form>

<script>
$(document).ready(function(){
    
     @if ($customer_withdraw_request->status && $customer_withdraw_request->payment->payment_method === 'bank_payment')
     $("#txn_div").show()
    @endif

    
    $('#payment_option').on('change', function() {
      if ( this.value == 'bank_payment')
      {
        $("#txn_div").show();
      }
      else
      {
        $("#txn_div").hide();
      }
    });
    
    AIZ.plugins.bootstrapSelect('refresh');
});
</script>
